/*
 * @Description: 邀请记录
 * @Author: iamsmiling
 * @Date: 2021-06-12 16:56:52
 * @LastEditTime: 2021-06-14 17:46:39
 */
import 'package:credit_business_circle/R/R.dart';
import 'package:credit_business_circle/components/dash_border/dash_border.dart';

import 'package:credit_business_circle/domain/remote/invitation/invitation_record_entity.dart';
import 'package:flutter/material.dart';

class InvitationRecordCard extends StatelessWidget {
  final List<InvitationRecordEntity> records;
  const InvitationRecordCard({Key? key, required this.records})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(
          left: R.dimen.dp13, right: R.dimen.dp13, top: R.dimen.dp56),
      alignment: Alignment.center,
      padding: EdgeInsets.only(
          left: R.dimen.dp18,
          right: R.dimen.dp18,
          top: R.dimen.dp56,
          bottom: R.dimen.dp24),
      decoration: BoxDecoration(
          color: R.color.fffff9ef,
          borderRadius: BorderRadius.circular(R.dimen.sp12)),
      child: Stack(
        alignment: AlignmentDirectional.center,
        children: [
          Positioned(
            top: 0,
            child: Transform.translate(
              offset: Offset(0, -(R.dimen.dp16 + R.dimen.dp56)),
              child: Stack(
                alignment: AlignmentDirectional.center,
                children: [
                  Image.asset(R.image.invitationHook),
                  Text(
                    "邀请记录",
                    style: TextStyle(
                        fontSize: R.dimen.sp20,
                        color: R.color.ffffffff,
                        fontWeight: FontWeight.w600),
                  )
                ],
              ),
            ),
          ),
          Column(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Column(
                    children: [
                      Text.rich(TextSpan(
                          text: "14",
                          style: TextStyle(
                              fontSize: R.dimen.sp25,
                              color: R.color.ffff142a,
                              fontWeight: FontWeight.w600),
                          children: [
                            TextSpan(
                                text: "人",
                                style: TextStyle(
                                    fontSize: R.dimen.sp12,
                                    fontWeight: FontWeight.normal))
                          ])),
                      Container(
                        margin: EdgeInsets.only(
                            top: R.dimen.dp10, bottom: R.dimen.dp24),
                        child: Text(
                          "邀请好友",
                          style: TextStyle(
                              fontSize: R.dimen.sp13,
                              color: R.color.ff333333,
                              fontWeight: FontWeight.w600),
                        ),
                      )
                    ],
                  ),
                  Container(
                    alignment: Alignment.topCenter,
                    width: .5,
                    height: R.dimen.dp38,
                    color: R.color.ffdddddd,
                    margin: EdgeInsets.only(bottom: R.dimen.dp20),
                  ),
                  Column(
                    children: [
                      Text.rich(TextSpan(
                          text: "10",
                          style: TextStyle(
                              fontSize: R.dimen.sp25,
                              color: R.color.ffff142a,
                              fontWeight: FontWeight.w600),
                          children: [
                            TextSpan(
                                text: "人",
                                style: TextStyle(
                                    fontSize: R.dimen.sp12,
                                    fontWeight: FontWeight.normal))
                          ])),
                      Container(
                        margin: EdgeInsets.only(
                            top: R.dimen.dp10, bottom: R.dimen.dp24),
                        child: Text(
                          "有效好友",
                          style: TextStyle(
                              fontSize: R.dimen.sp13,
                              color: R.color.ff333333,
                              fontWeight: FontWeight.w600),
                        ),
                      )
                    ],
                  ),
                  Container(
                    width: .5,
                    height: R.dimen.dp38,
                    color: R.color.ffdddddd,
                    margin: EdgeInsets.only(bottom: R.dimen.dp20),
                  ),
                  Column(
                    children: [
                      Text.rich(TextSpan(
                          text: "14/30",
                          style: TextStyle(
                              fontSize: R.dimen.sp25,
                              color: R.color.ffff142a,
                              fontWeight: FontWeight.w600),
                          children: [
                            // TextSpan(
                            //     text: "人",
                            //     style: TextStyle(
                            //         fontSize: R.dimen.sp12,
                            //         fontWeight: FontWeight.normal))
                          ])),
                      Container(
                        margin: EdgeInsets.only(
                            top: R.dimen.dp10, bottom: R.dimen.dp24),
                        child: Text(
                          "领取VIP月卡",
                          style: TextStyle(
                              fontSize: R.dimen.sp13,
                              color: R.color.ff333333,
                              fontWeight: FontWeight.w600),
                        ),
                      ),
                    ],
                  ),
                ],
              ),
              Container(
                width: R.dimen.width,
                child: DashedRect(
                  strokeWidth: .5,
                  gap: 3,
                  color: R.color.ffdddddd,
                ),
              ),
              Container(
                child: DefaultTextStyle(
                    style: TextStyle(
                      color: R.color.ff4c6702,
                      fontSize: R.dimen.sp14,
                    ),
                    child: Column(
                      children: [
                        Container(
                          margin: EdgeInsets.symmetric(vertical: R.dimen.dp14),
                          child: Row(
                            children: [
                              Expanded(
                                  flex: 1,
                                  child: Text(
                                    "头像",
                                    textAlign: TextAlign.center,
                                  )),
                              Expanded(
                                  flex: 2,
                                  child: Text(
                                    "昵称",
                                    textAlign: TextAlign.center,
                                  )),
                              Expanded(
                                  flex: 2,
                                  child: Text(
                                    "状态",
                                    textAlign: TextAlign.center,
                                  )),
                              Expanded(
                                  flex: 2,
                                  child: Text(
                                    "时间",
                                    textAlign: TextAlign.center,
                                  )),
                            ],
                          ),
                        ),
                        for (InvitationRecordEntity record in records)
                          Container(
                            padding:
                                EdgeInsets.symmetric(vertical: R.dimen.dp8),
                            decoration: BoxDecoration(
                                color: R.color.ffffedd4.withOpacity(.5),
                                borderRadius:
                                    BorderRadius.circular(R.dimen.sp5)),
                            margin: EdgeInsets.only(bottom: R.dimen.dp10),
                            child: Row(
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: CircleAvatar(
                                      foregroundImage:
                                          NetworkImage(record.avatar),
                                      radius: R.dimen.sp17,
                                    )),
                                Expanded(
                                    flex: 2,
                                    child: Text(
                                      "不会游泳",
                                      textAlign: TextAlign.center,
                                      style: TextStyle(
                                          color: R.color.ff4a3d3e,
                                          fontSize: R.dimen.sp14),
                                    )),
                                Expanded(
                                    flex: 2,
                                    child: Text(
                                      "${record.valid ? '有效' : '无效'}",
                                      textAlign: TextAlign.center,
                                      style: TextStyle(
                                          fontWeight: FontWeight.w500,
                                          fontSize: R.dimen.sp14,
                                          color: R.color.ff111111),
                                    )),
                                Expanded(
                                    flex: 2,
                                    child: Text(
                                      "${record.date}",
                                      textAlign: TextAlign.center,
                                      style: TextStyle(
                                          fontSize: R.dimen.sp14,
                                          color: R.color.ff777777),
                                    ))
                              ],
                            ),
                          )
                      ],
                    )),
              )
            ],
          )
        ],
      ),
    );
  }
}
